from django import forms
from fractions import Fraction


class WeightsForm(forms.Form):
    weights = forms.JSONField(label="权重向量")

    weights.widget.attrs.update(rows=3)


class PreferenceForm(forms.Form):
    point = forms.ChoiceField(
        choices=zip(
            (Fraction(1, 9), Fraction(1, 7), Fraction(1, 5), Fraction(1, 3), 1, 3, 5, 7, 9),
            ('极端不重要', '强烈不重要', '明显不重要', '稍微不重要', '同样重要', '稍微重要', '明显重要', '强烈重要', '极端重要')),
        initial=1,
        widget=forms.Select(
            attrs={
                "placeholder": "相对重要程度",
                "class": "form-control"
            }
        )
    )


class EvaluationForm(forms.Form):
    point = forms.DecimalField(
        max_value=10,
        min_value=0,
        max_digits=2,
        widget=forms.NumberInput(
            attrs={
                "type": "range",
                "placeholder": "评分",
                "class": "form-control"
            }
        )
    )
